package it.struts.helloworld.services;

import it.struts.helloworld.model.Utenti;
import it.struts.helloworld.utils.HibernateUtils;

import org.hibernate.Query;
import org.hibernate.Session;

public class LoginService {
	
	Session sess;
	
	public Utenti retrieveDetails(String username, String password){
		
		try{
			sess= HibernateUtils.getSessionFactory();
			Query query = sess.createQuery("FROM Utenti WHERE username = :usern AND password = :psw");
			query.setParameter("usern",username);
			query.setParameter("psw", password);
			return (Utenti) query.uniqueResult();
		}
		catch(Exception exep){
			exep.printStackTrace();
		}
		
		return null;
	}
}
